package com.katze.boot.hadoop.service;

import com.katze.boot.hadoop.entity.HadoopEntity;
import com.katze.common.Message;
import feign.Response;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.net.URI;

@FeignClient(name = "hadoop", url = "#", contextId = "HadoopService")
public interface FeignHadoopService {

    @RequestMapping(value = "/list", method = RequestMethod.GET)
    Message list(URI uri, @RequestParam("path") String path, @RequestParam("status") String status);

    @RequestMapping(value = "/{method}", method = RequestMethod.POST)
    Message post(URI uri,  @PathVariable("method") String method, @RequestBody HadoopEntity entity);

    @RequestMapping(value = "/delete", method = RequestMethod.DELETE)
    Message delete(URI uri,  @RequestParam("path") String path);

    @RequestMapping(value = "/upload", method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    Message upload(URI uri, @RequestPart("file") MultipartFile file, @RequestParam("target") String path);

    @RequestMapping(value = "/download", method = RequestMethod.GET)
    Response download(URI uri, @RequestParam("path") String path);
}
